﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using UnityEngine;

// Token: 0x0200034B RID: 843
public class AudioLoader
{
	// Token: 0x060015DC RID: 5596 RVA: 0x0008DD64 File Offset: 0x0008BF64
	public AudioLoader()
	{
		this.audioClips = new Dictionary<string, AudioClip>();
	}

	// Token: 0x060015DD RID: 5597 RVA: 0x0008DD78 File Offset: 0x0008BF78
	public AudioClip LoadAudioClip(string clipName)
	{
		AudioClip audioClip;
		if (!this.audioClips.TryGetValue(clipName, out audioClip))
		{
			Debug.LogError("Audio file " + clipName + " not found.");
		}
		else
		{
			audioClip.name = clipName;
		}
		return audioClip;
	}

	// Token: 0x060015DE RID: 5598 RVA: 0x0008DDBC File Offset: 0x0008BFBC
	public void SearchAndLoadClips(List<string> folder)
	{
		List<string> list = (from x in IOManager.GetFileList(folder)
		select x.Value).ToList<string>();
		foreach (string path in list)
		{
			string extension = Path.GetExtension(path);
			if (!(extension != ".wav") || !(extension != ".ogg"))
			{
				string fileName = Path.GetFileName(path);
				if (fileName != null && !this.audioClips.ContainsKey(fileName))
				{
					this.audioClips.Add(fileName, this.LoadClip(path));
				}
			}
		}
	}

	// Token: 0x060015DF RID: 5599 RVA: 0x0008DE9C File Offset: 0x0008C09C
	private AudioClip LoadClip(string path)
	{
		WWW www = new WWW("file:///" + path);
		return www.GetAudioClip();
	}

	// Token: 0x04001893 RID: 6291
	private Dictionary<string, AudioClip> audioClips;
}
